package org.abacus.client.ui.view.login;

import org.abacus.client.ui.access.AccessDataFactory;
import org.abacus.client.ui.control.widgets.LShell;
import org.abacus.client.ui.view.FormView;
import org.abacus.dao.DaoFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;

public class CopyOfLoginView extends FormView {

	private static String serverUrl;

	Text serverUrlTtext;

	Text email;

	Text password;

	public static String getServerUrl() {
		return serverUrl;
	}

	@Override
	protected void initView() {
		super.initView();

		AccessDataFactory accessDataFactory = AccessDataFactory.getInstance();
		accessDataFactory.createAccessData(new String[] { "{47C4C09B-E453-43F5-99B1-B29B55190B9E}",
				"{DD4C1C6C-B567-408F-B680-10A5B5A5C043}" }, new LShell(FormView.display, SWT.DIALOG_TRIM));
		GridLayout gridLayout = null;

		shell.setText("登录");
		// Group group = new Group(shell, SWT.NONE);
		// {
		// gridLayout = new GridLayout();
		// gridLayout.numColumns = 2;
		// gridLayout.makeColumnsEqualWidth = false;
		//
		// gridLayout.verticalSpacing = 20;
		//
		// group.setLayout(gridLayout);
		// group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		// }
		// group.setText("登录信息");
		//
		// Label label = null;
		// Text text = null;
		//
		// label = new Label(group, SWT.PUSH);
		// label.setText("服务器地址:");
		// label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
		// false));
		//
		// serverUrlTtext = new Text(group, SWT.BORDER);
		// serverUrlTtext.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
		// true));
		// serverUrlTtext.setText("http://127.0.0.1:8080/chaoyangli.abacus/api");
		//
		// label = new Label(group, SWT.PUSH);
		// label.setText("用户名:");
		// label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
		// false));
		//
		// text = new Text(group, SWT.BORDER);
		// text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
		// text.setText("179084436@qq.com");
		// setScrollable("email", text);
		//
		// label = new Label(group, SWT.PUSH);
		// label.setText("密码:");
		// label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
		// false));
		//
		// text = new Text(group, SWT.BORDER | SWT.PASSWORD);
		// text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
		// text.setText("1");
		// setScrollable("password", text);
		//
		// Button button = null;
		//
		// Composite composite = new Composite(shell, SWT.NONE);
		// {
		// gridLayout = new GridLayout();
		// gridLayout.numColumns = 2;
		// gridLayout.makeColumnsEqualWidth = true;
		// composite.setLayout(gridLayout);
		// composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
		// false));
		// }
		// button = new Button(composite, SWT.PUSH);
		// button.setText("取消");
		// button.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
		// false));
		// button.addListener(SWT.Selection, new Listener() {
		// @Override
		// public void handleEvent(Event arg0) {
		// cancel();
		// }
		// });
		//
		// ok = button = new Button(composite, SWT.PUSH);
		// button.setText("确定");
		// button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true,
		// true));
		// button.addListener(SWT.Selection, new Listener() {
		// @Override
		// public void handleEvent(Event arg0) {
		// ok();
		// }
		// });
		centerShell(shell, 350, 260);
		shell.pack();
		shell.open();
	}

	private Button ok;

	@Override
	public void ok() {
		ok.setEnabled(false);
		try {
			serverUrl = serverUrlTtext.getText();
			getActionRequest().done(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void cancel() {
		ok.setEnabled(true);
	}

	@Override
	public void dispose() {
		getShell().dispose();
	}

}
